IF EXISTS(SELECT * FROM sysobjects WHERE name = 'generarCodigoCanal' AND type = 'P')
BEGIN
	DROP PROCEDURE generarCodigoCanal
END
GO
CREATE PROCEDURE generarCodigoCanal
AS
/*********************************************************************
	Resumen: Genera codigo de Canal
	Parametros:
**********************************************************************/		

BEGIN

	DECLARE @CodigoCanal INT
	SELECT @CodigoCanal = CONVERT(INT, ISNULL(MAX(t1.CodigoCanal), 0)) + 1 FROM Canal t1
	
	SELECT @CodigoCanal AS CodigoCanal
END